<template>
  <div>
    cart-test组件 计数器：{{ count }}
    <button @click="updateCount">+1</button>
  </div>
</template>

<script>
export default {
  name: 'CartTest',
  props: {
    count: {
      type: Number
    }
  },
  emits: ['update:count'],
  setup(props, { emit }) {
    console.log(props.count)
    const updateCount = () => {
      // 通知父组件，让父组件去修改
      emit('update:count', props.count + 1)
    }
    return { updateCount }
  }
}
</script>